package org.example.jwtdemo.service;

import org.example.jwtdemo.entity.User;
import org.example.jwtdemo.mapper.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class LoginService {
    @Autowired
    private UserMapper userMapper;

    public User login(User user) {
        User userDB = userMapper.login(user);
        if (userDB != null) {
            return userDB;
        }
        throw new RuntimeException("用户名或密码错误");
    }

    public User getUserById(Long id) {
        return userMapper.getUserById(id);
    }
}
